//
//  JQFYCustomNavigationView.m
//  JQFY
//
//  Created by 代辉 on 2017/8/18.
//  Copyright © 2017年 yannis. All rights reserved.
//

#import "JQFYCustomNavigationView.h"
#import <Masonry/Masonry.h>
#import "JQFYRhythmView.h"
#import "UIColor+Addition.h"
#import "JQFYUMShare.h"

#define margin 20

@implementation JQFYCustomNavigationView {
    JQFYRhythmView *_musicStatusView;
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupUI];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)setupUI
{
    // 返回按钮
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:backButton];
    [backButton setBackgroundImage:[UIImage imageNamed:@"WechatIMG5"] forState:UIControlStateNormal];
    [backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(margin * SCAL);
        make.centerY.equalTo(self);
        make.width.height.mas_equalTo(20 *SCAL);
    }];
    [backButton addTarget:self action:@selector(dissMissAction) forControlEvents:UIControlEventTouchUpInside];
    CGFloat x = DH_Screen_Width - margin * 2 * SCAL;
    CGFloat y = self.frame.size.height / 2 * SCAL + 10 * SCAL;

    // 分享
    UIButton *shareButton = [[UIButton alloc] initWithFrame:CGRectMake(x, y, margin * SCAL, margin * SCAL)];
    [shareButton setBackgroundImage:[UIImage imageNamed:@"Sharesocial"] forState:UIControlStateNormal];
    [self addSubview:shareButton];
    
    [shareButton addTarget:self action:@selector(shareAction) forControlEvents:UIControlEventTouchUpInside];
}


#pragma mark - 分享 -
- (void)shareAction {
    [[JQFYUMShare new] openShareWebPage];
}


- (void)dissMissAction
{
    [[NSNotificationCenter defaultCenter] postNotificationName:JQFYDissMissAction object:nil];
}
@end
